package cn.edu.scau.dao;

import cn.edu.scau.entity.NursingLevel;

import org.apache.ibatis.jdbc.SQL;
/**
 * 数据访问层NursingLevelSqlProvider：是接口NursingLevelMapper的补充，专门编写复杂的SQL语句
 * @author ZERO
 *
 */
public class NursingLevelSqlProvider {

    public String insertSelective(NursingLevel record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("nursinglevel");
        
        if (record.getNursinglevelid() != null) {
            sql.VALUES("nursingLevelID", "#{nursinglevelid,jdbcType=INTEGER}");
        }
        
        if (record.getNursinglevellevel() != null) {
            sql.VALUES("nursingLevelLevel", "#{nursinglevellevel,jdbcType=VARCHAR}");
        }
        
        if (record.getNursinglevelconfigurationcontent() != null) {
            sql.VALUES("nursingLevelConfigurationContent", "#{nursinglevelconfigurationcontent,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(NursingLevel record) {
        SQL sql = new SQL();
        sql.UPDATE("nursinglevel");
        
        if (record.getNursinglevellevel() != null) {
            sql.SET("nursingLevelLevel = #{nursinglevellevel,jdbcType=VARCHAR}");
        }
        
        if (record.getNursinglevelconfigurationcontent() != null) {
            sql.SET("nursingLevelConfigurationContent = #{nursinglevelconfigurationcontent,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("nursingLevelID = #{nursinglevelid,jdbcType=INTEGER}");
        
        return sql.toString();
    }
    
    public String findByNursinglevellevel(String nursinglevellevel){
    	SQL sql = new SQL();
    	sql.SELECT("nursingLevelID, nursingLevelLevel, nursingLevelConfigurationContent");
    	sql.FROM("nursinglevel");
    	if(nursinglevellevel!=null) {
    		sql.WHERE(" nursingLevelLevel like concat('%',#{nursinglevellevel},'%')");
    	}
    	return sql.toString();
	} 
}